﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Libs.Content;

public partial class Controls_Right_Talk : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        NewsWeb _NewsWeb = new NewsWeb();
        List<NewsWeb> list;
        list = _NewsWeb.GetList(51, 0, 1);

        if (list.Count == 0) return;

        _NewsWeb = list[0];
        hlTitle.Text = _NewsWeb.Title;
        hlTitle.NavigateUrl = _NewsWeb.Url;
        if (_NewsWeb.ImageUrl.Length > 0)
        {
            imgNews.ImageUrl = AppUtils.ImageUrl(_NewsWeb.ImageUrl, "106", "106");
            imgNews.Visible = true;
        }
        else
        {
            imgNews.Visible = false;
        }
        ltrLead.Text = _NewsWeb.SubLead;

        // Thông tin phản hồi
        NewsForum _NewsForum = new NewsForum();
        int total = 0;
        rptList.DataSource = _NewsForum.GetList(_NewsWeb.NewsID, 2, 1, 3, ref total);
        rptList.DataBind();
    }

    protected string SubString(string s, int length)
    {
        if (s.Length > length)
        {
            s = s.Substring(0, length) + "...";
        }
        return s;
    }
}